<?php session_start() ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>.: BYKOM :: Web.Cliente : Publicidad.</title>

<?php include ("config.php");
	  require_once('JSON.php');
  	  require_once('utils.php');
	  require_once(ROOT_DIR_CLASES.'/cCliente.php');	  
  	  $LOGIN = unserialize($_SESSION['loginClass']);	  	  
	  $json = new Services_JSON();
	  $loginJSON = $json->encode($LOGIN);	  
?>
<link rel="stylesheet" href="<?php echo ESTILO?>/welcome.css" type="text/css" media="screen" charset="utf-8"/>
<script language="javascript" src="js/json.js"></script>
<script language="javascript" src="js/myClass/MyClass.js"></script>
<script language="javascript" src="js/myClass/MyAjax.js"></script>
<script language="javascript" src="js/json.js"></script>
</head>
<body onLoad="onLoad();">
<FORM NAME='frmPrincipal' ACTION='principal2.php' METHOD='post'> 
               <input type='hidden' name='val'  id="val">
               <input type='hidden' name='val2' id="val2">
</FORM>               
<table width="100%" height="90%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center" valign="middle" class="textWelcome">
      <div class="publicidadBGimage">    	
	  <table width="486" height="400" border="0" cellpadding="0" cellspacing="0"> 
      	<tr>
	        <td height="100" colspan="2" align="center" valign="middle">
            	<img src="imagenes/publicidadTop.gif" border="0" />
            </td>
        </tr>
        <tr>
	        <td height="250" colspan="2" align="center" valign="middle" style="border-top:#999999 dashed 1px;">
            	<div id="content" style="width:465px; height:250px; overflow:auto; padding:0px; margin:0px;">
                </div>
        	</td>       
        </tr>
        <tr>
        	<td valign="middle" style="border-top:#999999 dashed 1px;">
        		<span style="position: relative; font-size:13px; color:#999999;" >
                	<?php if (isset($_POST['canCheck'])&&($_POST['canCheck']==1)){ ?>
	                	<input type="checkbox" id="checkPub"> No volver a mostrar esta publicidad
                    <?php } ?>
                </span>
        	</td>
        	<td align="center" valign="middle" style="border-top:#999999 dashed 1px;" >
           		<span style="position: relative;">
               		<input name="Btn" type="button" onClick="continuar();" class="btnWelcome" value="continuar" />
          		</span> 
       		</td>           
        </tr>
      </table>
      </div>
    </td>
  </tr>
</table>
</body>
<script type="text/javascript">	
	var LOGIN = '<?= $loginJSON ?>'.parseJSON();
	var flagCharge = false;
	function onLoad(){				
		if (flagCharge==true) return;
		//CARGA DE PUBLICIDAD
		flagCharge = true;
		var params = { COMMAND: "CARGAR",
					   PUBLICIDAD: <?= $_POST['publicidadId'] ?>
					 };	
		var myAjax = new MyAjax();
		var onReady = function(req){
						     var publicidadJSON = req.responseText.parseJSON();
							 if ((publicidadJSON.length != 'undefined')&&(publicidadJSON.length>0)) {
								document.getElementById('content').innerHTML = unescape(publicidadJSON[0].html);	
							 }									 							 
							 flagCharge = 0;							
						  };
		var onError = function(req){
							document.getElementById('content').innerHTML = "error!";
							flagCharge = 0;	 
						  };
		myAjax.send('persistirpublicidad.php', params, onReady, onError);
	}
	
	function continuar(){
		var check = document.getElementById('checkPub');
		if ((check!=null)&&(check.checked)){
			var params = { COMMAND: "SAVECHECK",
					   	   PUBLICIDAD: <?= $_POST['publicidadId'] ?>,
						   CUENTA: LOGIN.tablaId,
						   OBJETIVO: LOGIN.objetivo
					 	 };	
			var myAjax = new MyAjax();
			var beforeAjaxSend = function(){frmPrincipal.submit();};
			myAjax.send('persistirpublicidad.php', params, beforeAjaxSend);
		}
		else
			frmPrincipal.submit();
	}
</script>
</html>
